/*
 * $Id: mirror.h,v 1.30.6.2 Broadcom SDK $
 * 
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 * 
 * DO NOT EDIT THIS FILE!
 * This file is auto-generated.
 * Edits to this file will be lost when it is regenerated.
 */

#ifndef __BCM_MIRROR_H__
#define __BCM_MIRROR_H__

#include <bcm/types.h>

/* Mirror modes for bcm_mirror_mode_set/get. */
#define BCM_MIRROR_DISABLE      0          /* Disable mirroring. */
#define BCM_MIRROR_L2           1          /* Enable mirroring. */
#define BCM_MIRROR_L2_L3        2          /* Deprecated. */

/* Flags for bcm_mirror_port_set/get. */
#define BCM_MIRROR_PORT_ENABLE      0x00000001 /* Enable mirroring. */
#define BCM_MIRROR_PORT_INGRESS     0x00000002 /* Ingress mirroring. */
#define BCM_MIRROR_PORT_EGRESS      0x00000004 /* Egress mirroring. */
#define BCM_MIRROR_PORT_EGRESS_TRUE 0x00000008 /* True egress mirroring. */
#define BCM_MIRROR_PORT_DEST_TRUNK  0x00000010 /* Parameter dest_port is a
                                                  trunk. */

/* Flags for bcm_mirror_destination_create/traverse. */
#define BCM_MIRROR_DEST_REPLACE             (1 << 0)   /* Replace mirror
                                                          destination. */
#define BCM_MIRROR_DEST_WITH_ID             (1 << 1)   /* Mirror destination id
                                                          is valid. */
#define BCM_MIRROR_DEST_TUNNEL_L2           (1 << 2)   /* Mirrored packet should
                                                          be L2 tunneled. */
#define BCM_MIRROR_DEST_TUNNEL_IP_GRE       (1 << 3)   /* Mirrored packet should
                                                          be L3 GRE tunneled. */
#define BCM_MIRROR_DEST_PAYLOAD_UNTAGGED    (1 << 4)   /* Strip vlan tag from
                                                          mrrored packet. */
#define BCM_MIRROR_DEST_TUNNEL_TRILL        (1 << 5)   /* Mirrored packet should
                                                          be TRILL tunneled. */
#define BCM_MIRROR_DEST_TUNNEL_NIV          (1 << 6)   /* Mirrored packet should
                                                          be NIV tunneled. */

/* Flags for mirror NIV tunneling */
#define BCM_MIRROR_NIV_LOOP     1          /* Mirrored packet is a loop in NIV
                                              path */

/* 
 * Mirror destination Structure
 * 
 * Contains information required for manipulating mirror destinations.
 */
typedef struct bcm_mirror_destination_s {
    bcm_gport_t mirror_dest_id;         /* Unique mirror destination and
                                           encapsulation identifier. */
    uint32 flags;                       /* See BCM_MIRROR_DEST_xxx flag
                                           definitions. */
    bcm_gport_t gport;                  /* Mirror destination. */
    uint8 version;                      /* IP header version. */
    uint8 tos;                          /* Traffic Class/Tos byte. */
    uint8 ttl;                          /* Hop limit. */
    bcm_ip_t src_addr;                  /* Tunnel source ip address (IPv4). */
    bcm_ip_t dst_addr;                  /* Tunnel destination ip address (IPv4). */
    bcm_ip6_t src6_addr;                /* Tunnel source ip address (IPv6). */
    bcm_ip6_t dst6_addr;                /* Tunnel destination ip address (IPv6). */
    uint32 flow_label;                  /* IPv6 header flow label field. */
    bcm_mac_t src_mac;                  /* L2 source mac address. */
    bcm_mac_t dst_mac;                  /* L2 destination mac address. */
    uint16 tpid;                        /* L2 header outer TPID. */
    bcm_vlan_t vlan_id;                 /* Vlan id. */
    bcm_trill_name_t trill_src_name;    /* TRILL source bridge nickname */
    bcm_trill_name_t trill_dst_name;    /* TRILL destination bridge nickname */
    int trill_hopcount;                 /* TRILL hop count */
    uint16 niv_src_vif;                 /* Source Virtual Interface of NIV tag */
    uint16 niv_dst_vif;                 /* Destination Virtual Interface of NIV
                                           tag */
    uint32 niv_flags;                   /* NIV flags BCM_MIRROR_NIV_XXX */
} bcm_mirror_destination_t;

/* Mirror destination callback function prototype. */
typedef int (*bcm_mirror_destination_traverse_cb)(
    int unit, 
    bcm_mirror_destination_t *mirror_dest, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Initialize the mirroring module to its initial configuration. */
extern int bcm_mirror_init(
    int unit);

/* Set the current mirroring mode for the device. */
extern int bcm_mirror_mode_set(
    int unit, 
    int mode);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize a bcm_bcm_mirror_destination_t structure. */
extern void bcm_mirror_destination_t_init(
    bcm_mirror_destination_t *mirror_dest);

#ifndef BCM_HIDE_DISPATCHABLE

/* Create a mirror (destination, encapsulation) pair. */
extern int bcm_mirror_destination_create(
    int unit, 
    bcm_mirror_destination_t *mirror_dest);

/* Get  mirror (destination, encapsulation) pair. */
extern int bcm_mirror_destination_get(
    int unit, 
    bcm_gport_t mirror_dest_id, 
    bcm_mirror_destination_t *mirror_dest);

/* Destroy a mirror (destination, encapsulation) pair. */
extern int bcm_mirror_destination_destroy(
    int unit, 
    bcm_gport_t mirror_dest_id);

/* Traverse installed mirror destinations. */
extern int bcm_mirror_destination_traverse(
    int unit, 
    bcm_mirror_destination_traverse_cb cb, 
    void *user_data);

/* Get the current mirroring mode for the device. */
extern int bcm_mirror_mode_get(
    int unit, 
    int *mode);

/* Set the mirror-to port for the device. */
extern int bcm_mirror_to_set(
    int unit, 
    bcm_port_t port);

/* Get the mirror-to port for the device. */
extern int bcm_mirror_to_get(
    int unit, 
    bcm_port_t *port);

/* Enable or Disable ingress mirroring for a port on the device. */
extern int bcm_mirror_ingress_set(
    int unit, 
    bcm_port_t port, 
    int val);

/* 
 * Get the ingress mirroring enabled/disabled status for a port on the
 * device.
 */
extern int bcm_mirror_ingress_get(
    int unit, 
    bcm_port_t port, 
    int *val);

/* Enable or Disable egress mirroring for a port on the device. */
extern int bcm_mirror_egress_set(
    int unit, 
    bcm_port_t port, 
    int val);

/* 
 * Get the egress mirroring enabled/disabled status for a port on the
 * device.
 */
extern int bcm_mirror_egress_get(
    int unit, 
    bcm_port_t port, 
    int *val);

/* Enable or Disable mirroring preserve format control. */
extern int bcm_mirror_pfmt_set(
    int unit, 
    int val);

/* Get the current preserve format control setting. */
extern int bcm_mirror_pfmt_get(
    int unit, 
    int *val);

/* Set the mirror-to port bitmap for the device. */
extern int bcm_mirror_to_pbmp_set(
    int unit, 
    bcm_port_t port, 
    bcm_pbmp_t pbmp);

/* Get the mirror-to port bitmap for the device. */
extern int bcm_mirror_to_pbmp_get(
    int unit, 
    bcm_port_t port, 
    bcm_pbmp_t *pbmp);

/* Set mirroring configuration for a port. */
extern int bcm_mirror_port_set(
    int unit, 
    bcm_port_t port, 
    bcm_module_t dest_mod, 
    bcm_port_t dest_port, 
    uint32 flags);

/* Get mirroring configuration for a port. */
extern int bcm_mirror_port_get(
    int unit, 
    bcm_port_t port, 
    bcm_module_t *dest_mod, 
    bcm_port_t *dest_port, 
    uint32 *flags);

/* Set VLAN for egressing mirrored packets on a port (RSPAN). */
extern int bcm_mirror_vlan_set(
    int unit, 
    bcm_port_t port, 
    uint16 tpid, 
    uint16 vlan);

/* Get VLAN for egressing mirrored packets on a port (RSPAN). */
extern int bcm_mirror_vlan_get(
    int unit, 
    bcm_port_t port, 
    uint16 *tpid, 
    uint16 *vlan);

/* Set egress mirror packet path for stack ring. */
extern int bcm_mirror_egress_path_set(
    int unit, 
    bcm_module_t modid, 
    bcm_port_t port);

/* Get current egress mirror packet path. */
extern int bcm_mirror_egress_path_get(
    int unit, 
    bcm_module_t modid, 
    bcm_port_t *port);

/* bcm_mirror_port_dest_add */
extern int bcm_mirror_port_dest_add(
    int unit, 
    bcm_port_t port, 
    uint32 flags, 
    bcm_gport_t mirror_dest_id);

/* bcm_mirror_port_dest_delete */
extern int bcm_mirror_port_dest_delete(
    int unit, 
    bcm_port_t port, 
    uint32 flags, 
    bcm_gport_t mirror_dest_id);

/* bcm_mirror_port_dest_delete_all */
extern int bcm_mirror_port_dest_delete_all(
    int unit, 
    bcm_port_t port, 
    uint32 flags);

/* bcm_mirror_port_dest_get */
extern int bcm_mirror_port_dest_get(
    int unit, 
    bcm_port_t port, 
    uint32 flags, 
    int mirror_dest_size, 
    bcm_gport_t *mirror_dest, 
    int *mirror_dest_count);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Backward compatibility. */
#define bcm_mirror_mode         bcm_mirror_mode_set 

#endif /* __BCM_MIRROR_H__ */
